App.EditSalesOrders = function(ds, grid, rowIndex) {
	//获取修改行的数据
	var record = grid.getStore().getAt(rowIndex);
//	alert(record.get("namelist_name"));
	
	var storeDept = new Ext.data.Store({
			baseParams : {
				trancode : 'Dept'
			},
	         proxy: new Ext.data.HttpProxy({
	                url:'../'+WebServiceUrl
	            }),
	            reader: new Ext.data.JsonReader({root: 'root'},[
	            	{name:'idtDept',type:'int'},
	                {name:'deptName',type:'string'}
	                
	         ])
	});
	var deptId=new Ext.form.ComboBox({
          store:storeDept,
          allowBlank:false,
          triggerAction:'all',
          displayField:'deptName',
          tabIndex : 1,
          valueField:'idtDept',
          fieldLabel:'部门名称',
          hiddenName:'idtDept',
          model:'remote',
          editable:false, 
          anchor:'70%',
          emptyText:'请选择部门名称'
   }); 
   
   /**
	 * 订单类型菜单
	 */
	var storeOrderType = new Ext.data.Store({
			baseParams : {
				trancode : 'OrderType'
			},
	         proxy: new Ext.data.HttpProxy({
	                url:'../'+WebServiceUrl
	            }),
	            reader: new Ext.data.JsonReader({root: 'root'},[
	                {name:'ordername',type:'string'},
	                {name:'idtOrdertype',type:'int'}
	         ])
	});
	var orderName=new Ext.form.ComboBox({
          store:storeOrderType,
          allowBlank:false,
          triggerAction:'all',
          displayField:'ordername',
          tabIndex : 4,
          valueField:'idtOrdertype',
          fieldLabel:'订单类型',
          hiddenName:'idtOrdertype',
          model:'remote',
          editable:false, 
          anchor:'70%',
          emptyText:'请选择订单类型'
   }); 
   
   /**
	 * 销售渠道菜单
	 */
	var storeSaleChannel = new Ext.data.Store({
			baseParams : {
				trancode : 'SaleChannel'
			},
	         proxy: new Ext.data.HttpProxy({
	                url:'../'+WebServiceUrl
	            }),
	            reader: new Ext.data.JsonReader({root: 'root'},[
	                {name:'meaning',type:'string'},
	                {name:'salesChannelCode',type:'int'}
	         ])
	});
	var meaning=new Ext.form.ComboBox({
          store:storeSaleChannel,
          allowBlank:false,
          triggerAction:'all',
          displayField:'meaning',
          tabIndex : 7,
          valueField:'salesChannelCode',
          fieldLabel:'销售渠道',
          hiddenName:'salesChannelCode',
          model:'remote',
          editable:false, 
          anchor:'70%',
          loadingText : record.get("meaning"),
          emptyText:'请选择销售渠道'
   }); 
   
    /**
	 * 价目表菜单
	 */
	var storePriceList = new Ext.data.Store({
			baseParams : {
				trancode : 'PriceList'
			},
	         proxy: new Ext.data.HttpProxy({
	                url:'../'+WebServiceUrl
	            }),
	            reader: new Ext.data.JsonReader({root: 'root'},[
	                {name:'namelistName',type:'string'},
	                {name:'idtPricelist',type:'int'}
	         ])
	});
	
	var priceList=new Ext.form.ComboBox({
          store:storePriceList,
        //  allowBlank:false,
          triggerAction:'all',
          displayField:'namelistName',
          tabIndex : 7,
          valueField:'idtPricelist',
          fieldLabel:'价目表名称',
          hiddenName:'idtPricelist',
          model:'remote',
          editable:false, 
          anchor:'70%',
//          value:record.get("namelist_name"),
          emptyText:'请选择价目表名称'
   }); 


		var formPanel = new Ext.FormPanel({
		labelAlign : 'right',
		labelWidth : 90,
		frame : true,
		url :'../'+WebServiceUrl,
		bodyStyle : 'padding:5px 5px 0',
		width : 300,
		items : [{
			layout : 'column',
			items : [{
				columnWidth : .5,
				layout : 'form',
				items : [{
                    xtype:'textfield',
                    fieldLabel: '客户名称',
                    tabIndex : 1,
					maxLength : 20,
					minLength : 1,
					allowBlank : false,
                    name: 'customer_name',
                    id:'customer_name',
                    value:record.get("customer_name"),
                    anchor:'70%'
                }, {
					xtype : 'combo',
					store : new Ext.data.SimpleStore({
						fields : ["freight_terms_id", "orderdeptName"],
						data : [['0', '我方承担'], ['1', '对方承担'], ['2', '共同承担']]
					}),
					valueField : "freight_terms_id",
					displayField : "orderdeptName",
					mode : 'local',
					forceSelection : true,
					tabIndex : 2,
					blankText : '请选择运费承担方式',
					emptyText : '选择运费承担方式',
					hiddenName : 'freight_terms_id',
					editable : false,
					triggerAction : 'all',
					allowBlank : false,
					fieldLabel : '运费承担方式',
					anchor : '70%'
				}]
			}, {
				columnWidth : .5,
				layout : 'form',
				items : [orderName,priceList]
			}, {
				columnWidth : .5,
				layout : 'form',
				items : [{
					xtype : 'textfield',
					fieldLabel : '销售人员',
					tabIndex : 5,
					maxLength : 20,
					minLength : 1,
					allowBlank : false,
					name : 'username2',
					id : 'username2',
					value:record.get("salesre_person"),
					anchor : '70%'
				}, {
					xtype : 'textfield',
					fieldLabel : '经 办 人',
					tabIndex : 6,
					maxLength : 20,
					minLength : 1,
					allowBlank : false,
					name : 'username1',
					id : 'username1',
					value:record.get("pesponsible"),
					anchor : '70%'
				}]
			}, {
				columnWidth : .5,
				layout : 'form',
				items : [meaning,deptId]
			}, {
				columnWidth : .5,
				layout : 'form',
				items : [{
					columnWidth : .5,
					layout : 'form',
					items : [{
						xtype : 'datefield',
						fieldLabel : '接单日期',
						format : "Y-m-d",
						tabIndex : 9,
						readOnly : true,
						allowBlank : false,
						name : 'ordered_date',
						id : 'ordered_date',
						anchor : '70%'
					}]
				}]
			}, {
				columnWidth : .5,
				layout : 'form',
				items : [{
					columnWidth : .5,
					layout : 'form',
					items : [{
					xtype : 'numberfield',
					fieldLabel : '定单金额',
					tabIndex : 8,
					maxLength : 20,
					minLength : 1,
					allowBlank : false,
					name : 'order_money',
					id : 'order_money',
					value:record.get("order_money"),
					anchor : '70%'
				},{
						xtype : 'textarea',
						fieldLabel : '备  注',
						tabIndex : 10,
						maxLength : 200,
						minLength : 1,
						name : 'remark',
						id : 'remark',
						value:record.get("remark"),
						anchor : '70%'
					}]
				}]
			}]
		}]
	});
	
	var winid = 'EditSalesOrders';
	var win = new Ext.Window({
		title : '修改销售信息',
		width : '80%',
		height :500,
		id : winid,
		layout : 'fit',
		plain : true,
		bodyStyle : 'padding:5px;',
		buttonAlign : 'center',
		resizable : false,
		items : formPanel,
		modal : true,
		buttons : [{
			text : '保存',
			tabIndex : 24,
			handler : function() {
				if (formPanel.form.isValid()) {
					formPanel.form.submit({
						waitTitle : "请稍候",
						waitMsg : '正在保存数据...',
						params : {
							trancode : '90043',
							id : record.get("idt_salesorders_h")
						},
						method : 'Post',
						failure : function(form, action) {
							Ext.MessageBox.alert('操作失败', action.result.message);
						},
						success : function(form, action) {
							if (action.result.success) {
								Ext.MessageBox.alert('操作成功',
										action.result.message);
								ds.load({params:{start:0, limit:App.pageSize}});
								Ext.getCmp(winid).close();
							} else {
							 	Ext.MessageBox.alert('操作失败',
										action.result.message);
							}
						}
					});
				} else {
					Ext.MessageBox.alert('输入错误', '请输完内容后再保存！');
				}
			}
		}, {
			text : '取消',
			tabIndex : 25,
			handler : function() {
				Ext.getCmp(winid).close();
			}
		}]
	});

	win.show();
};